const {jwtVerify} = require('../utils/utils')

//不需要登陆的接口，用户是否登陆
module.exports = async function (req, res, next) {
  if (!req.headers.authorization) {
    next()
  } else {
    const token = req.headers?.authorization?.split(' ')[1]
    const payload = await jwtVerify(token)
    req._id = payload?._id ?? ''
    next()
  }

}
